/*
 * Created on 10.10.2006 by leck
 *
 */
package de.devisnik.shifting.eidle;

import org.eclipse.core.runtime.Preferences;
import org.eclipse.core.runtime.preferences.AbstractPreferenceInitializer;

import de.devisnik.eidle.EidleActivator;
import de.devisnik.shifting.ShiftingActivator;

public class ShiftingPreferences extends AbstractPreferenceInitializer {

	private static final String DEFAULT_GLOBAL_IMAGE_PATH = EidleActivator
			.getDefault().getDataLocation();
	private static final int DEFAULT_GRID_X = 12;
	private static final int DEFAULT_GRID_Y = 9;
	private static final int DEFAULT_PRESENTATION_TIME = 20000;
	private static final int DEFAULT_SCRAMBLE_COUNT = 200;
	private static final int DEFAULT_SHOW_RESULT_TIME = 2000;
	private static final int DEFAULT_THINKING_TIME = 20;
	private static final int DEFAULT_SHIFTING_DELAY = 20;
	private static final boolean DEFAULT_USE_SCREENSHOT = true;

	static final String KEY_USE_SCREENSHOT = "use screenshot";
	static final String KEY_GLOBAL_IMAGE_PATH = "global_image_path";
	static final String KEY_GRID_X = "grid_x";
	static final String KEY_GRID_Y = "grid_y";
	static final String KEY_PRESENTATION_TIME = "presentation_time";
	static final String KEY_SCRAMBLE_COUNT = "scramble_count";
	static final String KEY_SHIFTING_DELAY = "shifting_delay";
	static final String KEY_SHOW_RESULT_TIME = "show_result_time";
	static final String KEY_THINKING_TIME = "thinking_time";

	private static Preferences getPreferences() {
		return ShiftingActivator.getDefault().getPluginPreferences();
	}

	public static String getGlobalImagePath() {
		return getPreferences().getString(KEY_GLOBAL_IMAGE_PATH);
	}

	public static int getGridX() {
		return getPreferences().getInt(KEY_GRID_X);
	}

	public static int getGridY() {
		return getPreferences().getInt(KEY_GRID_Y);
	}

	public static Integer getPresentationTime() {
		return new Integer(getPreferences().getInt(KEY_PRESENTATION_TIME));
	}

	public static int getScrambleCount() {
		return getPreferences().getInt(KEY_SCRAMBLE_COUNT);
	}

	public static int getShiftingDelay() {
		return getPreferences().getInt(KEY_SHIFTING_DELAY);
	}

	public static int getShowResultTime() {
		return getPreferences().getInt(KEY_SHOW_RESULT_TIME);
	}

	public static int getThinkingTime() {
		return getPreferences().getInt(KEY_THINKING_TIME);
	}

	public static boolean isUseScreenShot() {
		return getPreferences().getBoolean(KEY_USE_SCREENSHOT);
	}

	// @Override
	public void initializeDefaultPreferences() {
		final Preferences preferences = getPreferences();
		preferences
				.setDefault(KEY_GLOBAL_IMAGE_PATH, DEFAULT_GLOBAL_IMAGE_PATH);
		preferences
				.setDefault(KEY_PRESENTATION_TIME, DEFAULT_PRESENTATION_TIME);
		preferences.setDefault(KEY_GRID_X, DEFAULT_GRID_X);
		preferences.setDefault(KEY_GRID_Y, DEFAULT_GRID_Y);
		preferences.setDefault(KEY_THINKING_TIME, DEFAULT_THINKING_TIME);
		preferences.setDefault(KEY_SHIFTING_DELAY, DEFAULT_SHIFTING_DELAY);
		preferences.setDefault(KEY_SHOW_RESULT_TIME, DEFAULT_SHOW_RESULT_TIME);
		preferences.setDefault(KEY_SCRAMBLE_COUNT, DEFAULT_SCRAMBLE_COUNT);
		preferences.setDefault(KEY_USE_SCREENSHOT, DEFAULT_USE_SCREENSHOT);
	}

	public ShiftingPreferences() {
	}

}
